/**
 * Created by Francis.LW on 2017/10/20.
 *
 * 模块服务接口
 */
import {postRequest, getRequest} from '@/common/request'
import {urls} from './url'

const moduleApi = urls.module

function listAllModule(param, success, complete) {
  postRequest(moduleApi.listAllModule, {}, param, success, complete)
}

/**
 * 获取模块列表
 * @param param
 * @param page
 * @param pageSize
 * @param success
 * @param complete
 */
function listModule(param, page, pageSize, success, complete) {
  postRequest(moduleApi.listModule + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

/**
 * 创建新模块
 * @param param
 * @param success
 * @param complete
 */
function addModule(param, success, complete) {
  postRequest(moduleApi.addModule, {}, param, success, complete)
}

/**
 * 更新模块信息
 * @param id
 * @param param
 * @param success
 * @param complete
 */
function updateModule(id, param, success, complete) {
  postRequest(moduleApi.updateModule + id, {}, param, success, complete)
}

/**
 * 获取模块信息
 * @param id
 * @param success
 * @param complete
 */
function getModuleById(id, success, complete) {
  getRequest(moduleApi.getModuleById + id, {}, success, complete)
}

/**
 * 删除模块信息
 * @param ids
 * @param success
 * @param complete
 */
function deleteModule(ids, success, complete) {
  postRequest(moduleApi.removeModule, {}, ids, success, complete)
}

/**
 *
 * @param ids
 * @param success
 * @param complete
 */
function deleteSingleModule(id, success, complete) {
  let ids = []
  ids.push(id)
  deleteModule(ids, success, complete)
}

export default {
  listAllModule,
  listModule,
  addModule,
  updateModule,
  getModuleById,
  deleteModule,
  deleteSingleModule
}
